<?php
    /*-------------------------------------------------------+
     | PHP-Fusion Content Management System
     | Copyright (C) 2002 - 2011 Nick Jones
     | http://www.php-fusion.co.uk/
     +--------------------------------------------------------+
     | Filename: captcha_check.php
     | Author: Hans Kristian Flaatten
     +--------------------------------------------------------+
     | This program is released as free software under the
     | Affero GPL license. You can redistribute it and/or
     | modify it under the terms of this license which you
     | can read by viewing the included agpl.txt or online
     | at www.gnu.org/licenses/agpl.html. Removal of this
     | copyright header is strictly prohibited without
     | written permission from the original author(s).
     +--------------------------------------------------------*/
    
    $current_file_path = dirname(__FILE__);
    require_once ($current_file_path . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'maincore.php');
    
    if (isset($_POST['captcha_code'])) {
        
        $code = (isset($_POST['captcha_code']) ? stripinput($_POST['captcha_code']) : "");
        
        dbquery("DELETE FROM ".DB_PREFIX."validation_codes WHERE validation_datestamp < ".time());
                
        if (dbrows(dbquery("SELECT * FROM ".DB_PREFIX."validation_codes WHERE validation_code = '".$code."'")) >= 1)
        {
            $_CAPTCHA_IS_VALID = true;
        }
        else
        {
            $_CAPTCHA_IS_VALID = false;
        }
    }
    ?>
